/*
 * @Description: 配置相关页面
 * @Author: baimenghan
 * @Email: baimenghan@nnuo.com
 * @Date: 2022-02-25 09:23:10
 * @LastEditors: baimenghan
 * @LastEditTime: 2022-02-25 15:56:37
 * @FilePath: \daka\src\views\ConfigPage\ConfigPage.jsx
 */
import "./ConfigPage.sass";
import { Collapse } from "antd";
import { CaretRightOutlined } from "@ant-design/icons";
import { getAllConfigApi } from "@/api/configApi";
import PanelContent from "../../components/PanelContent/PanelContent";
import { useState } from "react";
import { useEffect } from "react";
import { chineseTransform } from "@/utils/common";
// import emitter from "@/services/event";

const { Panel } = Collapse;

function ConfigPage() {
  const [PanelBox, setPanelBox] = useState();
  useEffect(() => {
    getAllConfigApi().then((res) => {
      setPanelBox(
        res.map((item, index) => {
          return (
            <Panel
              header={chineseTransform(item.configName)}
              key={index}
              className="collapse-panel"
            >
              <PanelContent config={item} />
            </Panel>
          );
        })
      );
    });
  }, []);
  return (
    <div className="collapse-box">
      <Collapse
        bordered={false}
        defaultActiveKey={["0"]}
        expandIcon={({ isActive }) => (
          <CaretRightOutlined rotate={isActive ? 90 : 0} />
        )}
        className="collapse"
      >
        {PanelBox}
      </Collapse>
    </div>
  );
}

export default ConfigPage;
